<?php
session_start();
include("base_class.php");
$process = $_POST['process'];
$module = $_POST['module'];

switch($module) {
	case 'register':
		
    	$reg_obj = new BaseClass();
		switch($process) {
			case 'add_user':
				if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
							echo $reg_obj->newuser($_POST);
					unset($_SESSION['security_code']);
					}
				else
				{
					echo '<script>alert("Invalid Security Code")</script>';
				}
						echo '<script>location.href=\'../index.php?page=register&_suc=1\'</script>';
				break;
				
		}
		break;
		
		case 'password':
		$mail_obj = new BaseClass();
		switch($process) {
			case 'forgetid':
				echo $mail_obj->sendMail($_POST['email']);
				echo '<script>location.href=\'../index.php?page=forgot_password\'</script>';
			break;	
		}
		break;	
		
		case 'userlogin':
		$log_obj = new BaseClass();
		switch($process) {
			case 'log':
					$log_obj->Login($_POST['email'],$_POST['password']);
				
			break;	
		}
		break;
		
		case 'product':
		$reg_obj = new BaseClass();
		switch($process) {
			case 'sellproduct':
			$file="";
			if($_FILES["upload"]["name"]!="")
					{
					$file=gmdate('YmdHis').$_FILES["upload"]["name"] ;
					move_uploaded_file($_FILES["upload"]["tmp_name"],"../uploads/gadget_images/".$file);
					}
			     echo $reg_obj->sell_product($_POST,$file);
				 echo '<script>location.href=\'../index.php?page=logon&product=1\'</script>';
			break;	
		}
		break;
		
		case 'contact':
		$cont_obj = new BaseClass();
		switch($process) {
				case 'add_contact':
				if($_SESSION['securitycode'] == $_POST['securitycode'] && !empty($_SESSION['securitycode'] ) ) {					
							echo $cont_obj->contact($_POST);
					unset($_SESSION['securitycode']);
					}
				else
				{
					echo '<script>alert("Invalid Security Code")</script>';
				}
						echo '<script>location.href=\'../index.php?page=contact_us&rep=1\'</script>';
				break;	
		}
		break;
	case 'applyjob':
		$job_obj = new BaseClass();
		switch($process) {
			case 'sendjobmail':
				$file_name = "";
				$file_content = "";
				if($_FILES['attach']['name']!="") {
					$file_content = $_FILES['attach']['tmp_name'];
					$file_content = file_get_contents($file_content);
					$file_name = $_FILES['attach']['name'];
				}
			
				 
				echo $job_obj->Apply_job($_POST['to'],$_POST['my_sub'],$_POST['my_msg'],$_POST['my_email'],
										$file_name,$file_content);
				echo '<script>location.href=\'../index.php?page=apply_job&_sus=1\'</script>';
			break;	
		}
		break;	
		
	case 'banner_adverts':
		$base_obj = new BaseClass();
		switch($process) {
			case 'add_query':
				$array = array(
						 'email' => $_POST['email'],
						 'name' => $_POST['name'],
						 'advt_item' => $_POST['advt_item'],
						 'advt_days' => $_POST['advt_days'],
						 );
				
				$base_obj->insert_query('banner_ad_query',$array);
				mail('ida@ecstasoft.com',"Adverts Post Mail","A User is requesting for banner adverts");
				echo '<script>location.href=\'../index.php?page=thanks\'</script>';
			break;	
		}
		break;	
		case 'book':
		$book_obj = new BaseClass();
		switch($process) {
			case 'sellbook':
			$file="";
					if($_FILES["upload"]["name"]!="")
					{
				
					$file=gmdate('YmdHis').$_FILES["upload"]["name"] ;
					move_uploaded_file($_FILES["upload"]["tmp_name"],"../uploads/books/".$file);
					}
			     echo $book_obj->book($_POST,$file);
				/* echo '<script>location.href=\'../index.php?page=logon&product=1\'</script>';*/
			break;	
		}
		break;
		case 'vote_module':
		$vote_obj = new BaseClass();
		switch($process) {
			case 'vote_process':
				   echo $vote_obj->Rate_univ($_POST);
				/* echo '<script>location.href=\'../index.php?page=logon&product=1\'</script>';*/
			break;	
		}
		break;
				
	}
?>